<?php
// +----------------------------------------------------------------------
// | Description: 系统配置
// +----------------------------------------------------------------------
// | Author: orchief
// +----------------------------------------------------------------------

namespace app\admin\controller;

use app\common\controller\ApiCommon;

class AppConfigs extends ApiCommon
{
    public function _initialize()
    {
        parent::_initialize();
        // $this -> abort(!$this -> isClient, 'Permission denied', 403);
    }

    public function index()
    {
        $config = $this -> jsonConfig();
        $this->jsonData($config);
    }

    public function save()
    {
        // $res = $this -> jsonConfig('wechat.app_id', '1212');
        // // p($this->param);
        foreach($this->param as $k => $v){
            if(is_array($v)){
                foreach($v as $kk => $vv){
                    // p($k.'.'.$kk);
                    $res = $this -> jsonConfig($k.'.'.$kk, $vv);    // 一项一项存 这里只有后台操作 效率不考虑了
                }
                $this -> abort($res, '保存失败!');
            }
        }
        $this->checkRes($res, '添加成功');
    }
}
